package com.platform.core.entity;

import com.platform.comm.constraints.CExport;
import com.platform.comm.constraints.CImport;
import com.platform.comm.validation.groups.Batch;
import com.platform.comm.enums.YnEnum;
import com.platform.enums.CommFlagType;
import com.platform.enums.converters.CommFlagTypeConverter;
import com.platform.validator.Mobile;
import com.platform.validator.UserName;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * Description: 用户
 *
 * @author libin Created on 2019/7/15
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@Table(name = "ncloud_sys_user")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SysUserConfig extends CommConfig {

    private static final long serialVersionUID = -2114137089567983648L;

    private String sheetName = "用户管理";

    /**
     * 用户名
     */
    @Column(name = "user_name")
    @NotEmpty(message = "登录名不能为空",groups = Batch.class)
    @Size(min = 3,message = "登录名长度不能小于3",groups = Batch.class)
    @UserName(message="登录名只能以字母开头的字母、数字和下划线组合",groups = Batch.class)
    @CExport(name = "登录名称")
    @CImport(name = "登录名称")
    private String username;

    /**
     * 真实姓名
     */
    @Column(name = "user_real_name")
    @NotEmpty(message = "真实名称不能为空",groups = Batch.class)
    @CExport(colNum = "1",name = "真实名称")
    @CImport(colNum = "1",name = "真实名称")
    private String realName;

    /**
     * 密码
     */
    @Column(name = "user_password")
    private String password;

    /**
     * 密码过期时间，单位：天
     */
    @Column(name = "pwd_limit_days")
    private Integer pwdLimitDays;

    /**
     * 密码修改日期
     */
    @Column(name = "pwd_modify_date")
    private LocalDateTime pwdModifyDate;

    /**
     * 部门ID
     */
    @Column(name = "depart_id", length = 36)
    private String departId;

    /**
     * 状态标志
     */
    @Column(name = "delflag")
    private YnEnum delFlag;

    /**
     * 用户状态
     */
    @Column(name = "user_status")
    @Convert(converter = CommFlagTypeConverter.class)
    private CommFlagType status;

    /**
     * 邮箱地址
     */
    @Column(name = "email", length = 64)
    @CExport(colNum = "3",name = "电子邮件")
    private String email;

    /**
     * 手机号码
     */
    @Column(name = "mobile_phone", length = 30)
    @Mobile(message = "手机号号码不正确",groups = Batch.class)
    @CExport(colNum = "2",name = "手机号码")
    @CImport(colNum = "2",name = "手机号码")
    private String mobile;

    /**
     * 排序
     */
    @Column(name = "sort_num")
    private Integer sortNum;

    /**
     * 备注
     */
    @CExport(colNum = "4",name = "备注")
    @Column(name = "remark")
    private String remark;

    /**
     * 用户编码
     */
    @Column(name = "user_code")
    private String userCode;

    /**
     * 所属管理域
     */
    @Column(name = "manage_domain")
    private String domain;

    /**
     * 导入任务Id
     */
    @Column(name = "import_id")
    private String importId;

    /**
     * 批量导入状态
     */
    @Column(name = "import_check_flag")
    private String importCheckFlag;

    /**
     * 批量导入信息
     */
    @Column(name = "check_err_msg")
    private String checkErrMsg;

    /**
     * 首次登录系统时间
     */
    @Column(name = "first_login_date")
    private LocalDateTime firstLoginDate;

    /**
     * 创建时间
     */
    @Column(name = "create_date")
    private LocalDateTime createDate;


    /**
     * 修改时间
     */
    @Column(name = "update_date")
    private LocalDateTime updateDate;


    @Column(name = "id")
    private String id;
}
